package com.binarylei.kafka.api;

import org.apache.curator.framework.CuratorFramework;
import org.apache.curator.framework.CuratorFrameworkFactory;
import org.apache.curator.retry.ExponentialBackoffRetry;
import org.apache.zookeeper.CreateMode;

/**
 * @author leigang
 * @version 2019-08-23
 * @since 2.0.0
 */
public class ZookeeperTest {

    public static void main(String[] args) throws Exception {
        CuratorFramework cf = CuratorFrameworkFactory.builder()
                .connectString("192.168.139.101:2181")
                .sessionTimeoutMs(5000)
                .retryPolicy(new ExponentialBackoffRetry(1000, 10))
                .build();
        cf.start();

        cf.create().creatingParentsIfNeeded().withMode(CreateMode.PERSISTENT)
                .forPath("/test", "curator".getBytes());
    }
}
